<template>
	<view class="task">
		<view class="banner">
			<view class="title">
				<view class="title_name">
					任务管理
				</view>
				<view class="info">
					做任务，躺在赚钱
				</view>
			</view>
		</view>
		<view class="content_box">
			<view class="content_list">
				<view v-for="(item,index) in list" class="item">
					<view class="left">
						<image v-if="item.serialNumber==1" src="../../static/tabsIcon/task/qd.png" mode=""></image>
						<image v-if="item.serialNumber==2" src="../../static/tabsIcon/task/shiming.png" mode=""></image>
						<image v-if="item.serialNumber==3" src="../../static/tabsIcon/task/guangao.png" mode=""></image>
						<image v-if="item.serialNumber==4" src="../../static/tabsIcon/task/shipin.png" mode=""></image>
						<image v-if="item.serialNumber==5" src="../../static/tabsIcon/task/tupian.png" mode=""></image>
						<image v-if="item.serialNumber==6" src="../../static/tabsIcon/task/dz.png" mode=""></image>
						<image v-if="item.serialNumber==7" src="../../static/tabsIcon/task/ly.png" mode=""></image>
						<view class="content_task">
							<view class="top">
								<view class="name">
									{{item.name}}
								</view>
								<view class="gold">
									+ {{item.rewardsNum}}
								</view>
							</view>
							<view class="bottom">
								{{item.description}}
							</view>
						</view>
					</view>
					<view class="right">
						<view v-if="item.isFinish==1" class="finish">
							已完成
						</view>
						<view @click="gofinish(item.serialNumber)" v-else class="nofinish">
							去完成
						</view>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		taskList
	} from '@/api/mine';
	import {
		bootbannergetBannerList
	} from '@/api/home'
	export default {
		data() {
			return {
				list: [],
				img: "",
			}
		},
		onShow() {
			this.gettaskList();
		},
		onLoad() {
			this.getimg();
		},
		methods: {
			gofinish(i) {
				if (i == 1) {
					uni.switchTab({
						url: "./mine"
					})
				} else if (i == 2) {
					uni.navigateTo({
						url: './realname'
					})
				} else if (i == 3) {
					uni.showToast({
						icon: 'none',
						title: '暂未开放'
					})
				} else if (i == 4 || i == 5) {
					uni.navigateTo({
						url: "../community/release"
					})
				} else if (i == 6 || i == 7) {
					uni.switchTab({
						url: "../community/community"
					})
				} else {
					uni.showToast({
						icon: 'none',
						title: '暂未开放'
					})
				}

			},
			getimg() {
				bootbannergetBannerList(19).then(res => {
					this.img = res.data[0].picturesLinking;
				})
			},
			gettaskList() {
				taskList().then(res => {
					if (res.success == 1) {
						this.list = res.data;
						console.log(this.list, res)
					} else {
						uni.showToast({
							icon: 'none',
							title: res.message
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: #f4f4f4;
	}

	.task {
		// width: 100%;
		// background-image: url(../../static/tabsIcon/taskbg.png);
		// background-repeat: no-repeat;
		// background-size: 100% 150px;
		// padding: 40rpx;
		// min-height: 50vh;
	}

	.banner {
		background: #fc6758;
		padding: 40rpx;
		height: 360rpx;
		display: flex;
		align-items: center;
		color: #fff;

		.title {
			.title_name {
				font-size: 40rpx;
				margin-bottom: 10rpx;
			}

			.info {
				font-size: 24rpx;
				color: rgba(255, 255, 255, 0.6);
			}
		}
	}

	.content_box {
		padding: 30rpx;
	}

	.content_list {
		position: relative;
		top: -100rpx;
		// width: 100%;
		// margin-top: 30rpx;
		background: #FFFFFF;
		border-radius: 30rpx;
		padding: 20rpx;

		.item {
			display: flex;
			align-items: center;
			justify-content: space-between;
			// margin-bottom: 20rpx;
			padding: 20rpx 0;
			// border-bottom: 2rpx solid rgba(151, 151, 151, 0.2);


			.left {
				width: 77%;
				display: flex;

				image {
					width: 80rpx;
					height: 80rpx;
					margin-right: 20rpx;
				}

				.content_task {
					width: calc(100% - 100rpx);
				}

				.top {
					display: flex;
					align-items: center;
					// justify-content: space-between;
					margin-bottom: 10rpx;

					.name {
						font-size: 30rpx;
						font-weight: bold;
						margin-right: 20rpx;
						color: #333333;
						// width: 50%;
					}

					.gold {
						display: flex;
						align-items: center;
						line-height: 30rpx;
						font-size: 28rpx;
						color: #FFCC00;

					}
				}

				.bottom {
					font-weight: 400;
					color: rgba(0, 0, 0, 0.38);
					font-size: 22rpx;
				}
			}

			.right {
				font-size: 22rpx;
				text-align: center;

				.finish {
					// background: #FC6758;
					color: #FC6758;
					border-radius: 18rpx;
					padding: 5rpx;
					width: 90rpx;
					text-align: center;
				}

				.nofinish {
					// background: #FC6758;
					color: #FC6758;
					width: 90rpx;
					text-align: center;
					padding: 5rpx;
					// color: rgba(0, 0, 0, 0.38);
					border: 1rpx solid #FC6758;
					border-radius: 20rpx;
				}
			}
		}
	}
</style>
